/*
 * Copyright (c) 2001, 2002 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.perforce.api;

/**
  * @version $Revision: 41 $
  * @author  <a href="mailto:bpruessmann@users.sourceforge.net>Boris Pruessmann</a>
  */
public interface IError
{
	// ----------------------------------------------------------------------------------- Constants
	
	/** action returned empty results */
	int EV_EMPTY   = 0x11;

	/** nothing yet */
	int E_EMPTY = 0x00;
	/** something good happened */
	int E_INFO = 0x01;
	/** something not good happened */
	int E_WARN = 0x02;
	/** user did somthing wrong */
	int E_FAILED = 0x03;
	/** system broken -- nothing can continue */
	int E_FATAL = 0x04;

	
	/** for info messages */
	int EF_PLAIN   = 0x00;
	/** indent each line with \t */
	int EF_INDENT  = 0x01;
	/** terminate buffer with \n */
	int EF_NEWLINE = 0x02;
	/** don't use P$LANGUAGE formats */	
	int EF_NOXLATE = 0x04;
	
	// ------------------------------------------------------------------------------------- Methods
	
	/** Call this method to dispose the IClientApi object */
	void dispose();
	
	/** Cleans the Error. */
	void clear();
	
	/** Determines whether an error condition is present.
	  * 
	  * @return true if error condition, false otherwise.
	  */
	boolean test();
	
	/** Checks whether the severity indicates an information.
	  * 
	  * @return true if severity indicates information.
	  */
	boolean isInfo();
	
	/** Checks whether severity indicates a warning.
	  * 
	  * @return true if the severity indicates warning,
	  */
	boolean isWarning();
	
	/** Checks whether the severity indicates a user of a system error.
	  * 
	  * @return true if severity indicates a user or system error.
	  */
	boolean isError();
	
	/** Checks whether severity indicates a system error.
	  * 
	  * @return true if severity indicates a system error.
	  */
	boolean isFatal();
	
	/** Calls this method to retrieve the Error's severity.
	  * 
	  * @return the Error's severity.
	  */
	int getSeverity();
	
	/** Converts the Error's severity into a String.
	  * 
	  * @return the severity string.
	  */
	String formatSeverity();
	
	/** Returns the generic code of the Error.
	  *
	  * @return generic error code.
	  */
	int getGeneric();
	
	/** Call this to format the Error message.
	  * 
	  * @param options can be any combination of EF_PLAIN, EF_INDENT, EF_NEWLINE or EF_NOXLATE.
	  * @return the error message.
	  */
	String format(int options);
}
